package comframe.jdbc.sql.datasource;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;

import javax.sql.DataSource;

import org.apache.log4j.Logger;


public class LoaclDataSource implements DataSource{
	private static Logger logger = Logger.getLogger(LoaclDataSource.class);
	private Config config;

	public LoaclDataSource(Config config) {
		this.config = config;
	}

	public Connection getConnection() throws SQLException {
		if(config!= null)
			try {
				return ConnFactory.getFactory().getConn(config);
			} catch (ClassNotFoundException e) {
				logger.error("数据库驱动JAR不存在");
			}
		return null;
	}

	public Connection getConnection(String userName, String Passowrd)
			throws SQLException {
		if(config!= null)
			try {
				return ConnFactory.getFactory().getConn(config);
			} catch (ClassNotFoundException e) {
				logger.error("数据库驱动JAR不存在");
			}
		return null;
	}

	public PrintWriter getLogWriter() throws SQLException {
		return null;
	}

	public int getLoginTimeout() throws SQLException {
		return 0;
	}

	public void setLogWriter(PrintWriter arg0) throws SQLException {
		
	}

	public void setLoginTimeout(int arg0) throws SQLException {
		
	}

	public <T> T unwrap(Class<T> iface) throws SQLException {
		return null;
	}

	public boolean isWrapperFor(Class<?> iface) throws SQLException {
		return false;
	}

	@Override
	public java.util.logging.Logger getParentLogger()
			throws SQLFeatureNotSupportedException {
		return null;
	}

	

}
